<?php
class AdminController extends Controller {
	var $user_info;
	public function AdminController(){
		parent::Controller();
		$this->module = 'admin';
		$this->page_title = '管理平台';
		
		//用户权限验证
		$this->user_info = get_session('visitor');
// 		print_r($this->user_info);exit;
		$public_requests = array(
			'site' => array('login', 'logout'),
		);
		if(!array_key_exists(APP, $public_requests) || !in_array(ACT, $public_requests[APP])){
			if(empty($this->user_info) || $this->user_info['has_login'] != true){
				//重新转向登录界面
				$this->redirect('/admin.php?act=login');
			}else{
				global $session_key;
				$session_expire = time() + intval(SESSION_EXPIRE);
				UCenter::update_user_state($this->user_info['_id'], $session_key, $session_expire);
			}
		}
	}
	
	protected function error($error_info, $links=array()){
		echo $error_info;
		exit;
	}
	
	protected function ajax_error($error_info){
		echo json_encode(array(
			'result' => false,
			'info'	=> $error_info,
		));
		exit;
	}
	
	protected function info($msg, $links=array()){
		echo $msg;
		exit;
	}
	
	protected function ajax_info($msg){
		echo json_encode(array(
			'result' => true,
			'info'	=> $msg,
		));
		exit;
	}
}

?>